package com.yijiu.response;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.yijiu.network.Response;
import com.yijiu.resource.BrokerageList;

/**
 * 请求佣金记录的响应
 * 
 * @author TangChao
 */
public class RequestBrokerageRecordResponse extends Response
{
	public List<BrokerageList> list;
	/**
	 * 累计佣金
	 */
	public String allAmount;
	/**
	 * 已收款佣金
	 */
	public String payedAmount;
	
	@Override
	protected void jsonToObject()
	{
		list = new ArrayList<BrokerageList>();
		try
		{
			JSONObject jsonObject = reposonJson.getJSONObject("result");
			allAmount = jsonObject.optString("allAmount");
			payedAmount = jsonObject.optString("payedAmount");
			JSONArray jsonArray = jsonObject.getJSONArray("infos");
			for (int i = 0; i < jsonArray.length(); i++)
			{
				BrokerageList brokerageList = new BrokerageList();
				JSONObject object = jsonArray.getJSONObject(i);
				brokerageList.investorName = object.optString("investorName");
				brokerageList.investAmount = object.optString("investAmount");
				brokerageList.brokerBenifitAmount = object.optString("brokerBenifitAmount");
				brokerageList.tradeId = object.optInt("tradeId");
				brokerageList.detailId = object.optInt("detailId");
				brokerageList.investDetailId = object.optInt("investDetailId");
				list.add(brokerageList);
			}
		}
		catch (JSONException e)
		{
			e.printStackTrace();
		}
	}
}
